#include<bits/stdc++.h>
using namespace std;
long long n,l,r,ans;
int main()
{
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	scanf("%lld%lld%lld",&n,&l,&r);ans=l%n;
	if(ans+(r-l)>=n)
	{
		ans=n-1;
	}
	else
	{
		ans=ans+(r-l);
	}printf("%lld",ans);
	return 0;
}
